IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[bd_kq_schedule_detail]') AND type IN ('U'))
	DROP TABLE [dbo].[bd_kq_schedule_detail]
GO
CREATE TABLE [dbo].[bd_kq_schedule_detail](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[user_serial] [bigint] NOT NULL,
	[shift_id] [int] NOT NULL,
	[shift_name] [varchar](30) NULL,
	[shift_date] [date] NOT NULL,
	[shift_begin] [int] NOT NULL,
	[shift_end] [int] NOT NULL,
	[shift_sign_begin] [int] NULL,
	[shift_sign_end] [int] NULL,
	[shift_late] [int] NULL,
	[shift_early] [int] NULL,
	[shift_duty_on_delay] [int] NULL,
	[shift_duty_off_delay] [int] NULL,
	[shift_workday] [varchar](50) NULL,
	[shift_workday_hours] [int] NULL,
	[is_enjoyment_subsidized] [int] NULL,
	[middle_shift_start_time] [int] NULL,
	[middle_shift_end_time] [int] NULL,
	[night_shift_start_time] [int] NULL,
	[night_shift_end_time] [int] NULL,
	[repast_start_time] [int] NULL,
	[repast_end_time] [int] NULL,
	[repast_start_time2] [int] NULL,
	[repast_end_time2] [int] NULL,
	[shift_is_rest] [int] NULL,
 CONSTRAINT [PK_BD_KQ_SCHEDULE_DETAIL] PRIMARY KEY CLUSTERED
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_id]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_begin]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_end]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_sign_begin]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_sign_end]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_late]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_early]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_duty_on_delay]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_duty_off_delay]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [shift_workday_hours]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [is_enjoyment_subsidized]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [middle_shift_start_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [middle_shift_end_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [night_shift_start_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [night_shift_end_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [repast_start_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [repast_end_time]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [repast_start_time2]
GO

ALTER TABLE [dbo].[bd_kq_schedule_detail] ADD  DEFAULT ((0)) FOR [repast_end_time2]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'id'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'user_serial'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'班次ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_id'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'[A|X]班次编号|班次名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_name'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排班日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_date'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排班开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_begin'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排班结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_end'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否是休息日(0，1)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'bd_kq_schedule_detail', @level2type=N'COLUMN',@level2name=N'shift_is_rest'
GO

